package CCF_2014;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class T201403_2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1[] = scanner.nextLine().split(" ");
        int n =  Integer.valueOf(str1[0]);
        int m =  Integer.valueOf(str1[1]);
        int area[] = new int[4];
        List<Window> windows = new ArrayList<>();
        for(int i=0;i<n;i++) {
            area = StringToInt(scanner.nextLine().split(" "));
            windows.add(new Window(i+1, area[0], area[1], area[2], area[3]));
        }
        int x,y;
        Window wd;
        boolean isClickWd = false;
        for(int i=0;i<m;i++) {
            str1 = scanner.nextLine().split(" ");
            x =  Integer.valueOf(str1[0]);
            y =  Integer.valueOf(str1[1]);
            for(int j=n-1;j>=0;j--) {
                wd = windows.get(j);
                if (wd.isInArea(x, y)) {
                    isClickWd = true;
                    System.out.println(wd.order);
                    windows.add(wd);
                    windows.remove(j);
                    break;
                }
            }
            if (!isClickWd) {
                System.out.println("IGNORED");
            }
            isClickWd = false;
        }
        scanner.close();
    }

    private static int[] StringToInt(String ss[]) {
        int array[] = new int[ss.length];
        for (int i=0;i<ss.length;i++) {
            array[i] = Integer.valueOf(ss[i]);
        }
        return array;
    }

    private static class Window {
        int order;
        int x1;
        int y1;
        int x2;
        int y2;

        public Window(int order,int x1,int y1,int x2,int y2) {
            this.order = order;
            this.x1 = x1;
            this.y1 = y1;
            this.x2 = x2;
            this.y2 = y2;
        }

        private boolean isInArea(int x,int y) {
            return x>=x1 && x<=x2 && y>=y1 && y<=y2;
        }
    }
}
